package main

import "fmt"

//多态
//接口定义方法的集合
//‍️结构体对象要实现接口定义的所有方法
//统一的函数调用入口，传入的接口
//

type notifer interface {
	notify()
	fff()
}

type user struct {
	name  string
	email string
}

type admin struct {
	name string
	age  int
}

func (u *user) fff() {
	fmt.Printf("the fff receiver %s\n", u.name)
}

func (u *admin) fff() {
	fmt.Printf("the fff receiver %s\n", u.name)
}

func (u *user) notify() {
	fmt.Printf("[guest user][sendNotify to user %s]\n", u.name)
}

func (u *admin) notify() {
	fmt.Printf("[admin user][sendNotify to user %s]\n", u.name)
}

func main() {
	u1 := user{
		name:  "guest",
		email: "qq.com",
	}
	a1 := admin{
		name: "lwq",
		age:  18,
	}

	//u1.notify()
	//a1.notify()
	ns := make([]notifer, 0)
	ns = append(ns, &u1)
	ns = append(ns, &a1)

	for _, n := range ns {
		//做统一的入口
		n.notify()
		n.fff()
	}
}
